import 'package:app/pages/login_modules/code_login_module/code_login_controller.dart';
import 'package:flutter/services.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';

import '../../../components/countdown_button_page.dart';
import '../../../components/gradient_button.dart';
import '../../../utils/phone_inputformatter.dart';
class CodeLoginView extends GetView{

  @override
  Widget build(BuildContext context) {

    CodeLoginController controller = Get.put(CodeLoginController());

    // TODO: implement build
    return Container(
      child: GetBuilder<CodeLoginController>(builder: (_){
        return ListView(
          children: [
            Center(
              child: Container(
                  decoration: new BoxDecoration(
                    // color: Colors.white,
                    //设置四周圆角 角度
                    borderRadius: BorderRadius.all(Radius.circular(25.0)),
                    //设置四周边框
                    border: new Border.all(
                        width: 0.5, color: Colors.white),
                  ),
                  margin: EdgeInsets.only(top: 20, left: 15, right: 15),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Container(

                          margin: EdgeInsets.only(left: 15),
                          width: 200,
                          child: Row(
                            children: [

                              GestureDetector(
                                onTap: () async {
                                  // var data = await  Get.to(SelectOptionsPage());
                                  // if(data!=null){
                                  //   options = data;
                                  //   setState(() {
                                  //
                                  //   });
                                  // }

                                },
                                child: Container(
                                  margin: EdgeInsets.only(top: 2),
                                  // color: Colors.red,
                                  child: Text(
                                    '${controller.options}', style: TextStyle(
                                      color: Colors.white),),
                                ),
                              ),
                              // TextButton(onPressed: (){
                              //   Get.to(SelectOptionsPage());
                              //
                              // }, child: Text('+86')),

                              Container(
                                padding: EdgeInsets.only(left: 5),
                                width: 160,
                                child: TextField(

                                  controller: controller.username,
                                  keyboardType: TextInputType.phone,
                                  style: TextStyle(
                                      fontSize: 16, color: Colors.white),
                                  inputFormatters: <TextInputFormatter>[
                                    LengthLimitingTextInputFormatter(13), //限制长度
                                    phoneInputFormatter(),
                                  ],
                                  decoration: InputDecoration(
                                    hintText: '请输入手机号码'.tr,
                                    hintStyle: TextStyle(fontSize: 16,

                                        color: Colors.white.withAlpha(50)),
                                    border: InputBorder.none,
                                    // prefixIcon: Icon(Icons.phone_android,size: 15,),
                                  ),
                                ),
                              )
                            ],
                          )
                      ),
                      CountdownButton(controller.username),
                    ],
                  )
              ),
            ),
            Center(
              child: Container(
                decoration: new BoxDecoration(
//背景
//                 color: Colors.white,
                  //设置四周圆角 角度

                  borderRadius: BorderRadius.all(Radius.circular(25.0)),
                  //设置四周边框
                  border: new Border.all(width: 0.5, color: Colors.white),


                ),

                margin: EdgeInsets.only(top: 10, right: 15, left: 15),
                child: Container(
                  margin: EdgeInsets.only(left: 25),
                  child: TextField(
                    inputFormatters: <TextInputFormatter>[
                      LengthLimitingTextInputFormatter(6)//限制长度
                    ],
                    controller: controller.pwd,
                    style: TextStyle(fontSize: 16, color:Colors.white),
                    keyboardType: TextInputType.number,
                    decoration: InputDecoration(
                      hintText: '请输入验证码'.tr,
                      hintStyle: TextStyle(fontSize: 16, color: Colors.white.withAlpha(50)),
                      border: InputBorder.none,
                      // prefixIcon: Image.asset(A.assets_pwd),
                    ),
                  ),
                ),
              ),
            ),


            // Container(
            //   padding: EdgeInsets.only(left: 25, top: 15, right: 25),
            //   child: Row(
            //     mainAxisAlignment: MainAxisAlignment.spaceBetween,
            //     children: [
            //       GestureDetector(
            //
            //         child: Text(
            //           '手势登录'.tr, style: TextStyle(fontSize: 14, color: HexColor(
            //             '#2A39E1')),),
            //         onTap: () {
            //           // Get.to(GesturePasswordWidgetDemo());
            //         },
            //       ),
            //       GestureDetector(
            //
            //         child: Text(
            //           '人脸登录'.tr, style: TextStyle(fontSize: 14, color: HexColor(
            //             '#2A39E1')),),
            //         onTap: () {
            //           // Get.to(FaceLoginPage());
            //         },
            //       ),
            //     ],
            //   ),
            // ),

            Container(
              margin: EdgeInsets.only(top: 72, right: 15, left: 15),
              width: Get.width,
              height: 45,
              child:GradientButton(
                child: Text('登录'),
                onPressed: (){
                  controller.tapClickRegister();
                },
                borderRadius: BorderRadius.all(Radius.circular(20)),
              )
              // MaterialButton(
              //   elevation: 0,
              //   shape: RoundedRectangleBorder(
              //     borderRadius: BorderRadius.circular(22),
              //   ),
              //   color: Theme
              //       .of(context)
              //       .primaryColor,
              //   onPressed: () async {
              //     controller.tapClickRegister();
              //     // requestDataWithCodeLogin(_username.text.replaceAll(new RegExp(r"\s+\b|\b\s"), ""), _pwd.text);
              //   },
              //   child: Text('登录'.tr, style: TextStyle(color: Colors.white),),
              // ),
            ),
          ],
        );
      }),
    );
}

}